package com.FundamentalDemos.Array;

public class 多个变量指向同一个数组对象的形式 {
    public static void main(String[] args) {
        int[] arr1 = {11, 22, 33};
        int[] arr2 = arr1;//arr1中存的数组对象的地址赋值给arr2
        System.out.println(arr1);
        System.out.println(arr2);
        arr2[1] = 99;
        System.out.println(arr1[1]);
        arr2 = null;//arr2不再指向数组arr1
        System.out.println(arr2);//null
//        System.out.println(arr2.length);//会发生空指针异常
//        System.out.println(arr2[0]);//也会发生空指针异常

    }
}
